﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Artech.Core.Caching
{
    /// <summary>
    /// Interface defining the behavior of the cache store.
    /// </summary>
    /// <typeparam name="T">The type of cache data.</typeparam>
    public interface ICacheStore<T>
    {
        /// <summary>
        /// Gets the data.
        /// </summary>
        /// <param name="key">The key of cache item.</param>
        /// <param name="getData">The delegate used to get the data which cannot be found from cache.</param>
        /// <returns>The data.</returns>
        T GetData(string key, Func<T> getData = null);

        /// <summary>
        /// Saves the data into cache.
        /// </summary>
        /// <param name="key">The key of cache item.</param>
        /// <param name="data">The data saved into cache.</param>
        void AddData(string key, T data);

        /// <summary>
        /// Clears all of cached data.
        /// </summary>
        void Clear();
    }
}